import Router from '#Routes/customRoute.js';
import { AuthController } from '#Controllers/index.js';
import { jwtMiddleware } from '#Middlewares/token.js';

const route = new Router();

route.get('/', async (ctx) => {
    ctx.body = 'Hello World!';
})

const testMiddleware = async (ctx, next) => {
    console.log('testMiddleware');
    await next();
}

const testMiddleware2 = async (ctx, next) => {
    console.log('testMiddleware2');
    await next();
}

route.group('/user', [testMiddleware], () => {
    return [
        ['post', '/login', AuthController.login],
        ['get', '/logout', AuthController.logOut],
        ['post', '/register', AuthController.register],

        ['get', '/index', AuthController.index],

        ['group', '/user1', [jwtMiddleware, testMiddleware2], () => {
            return [
                ['get', '/index', jwtMiddleware, AuthController.index1],
                ['get', '/index1', AuthController.index2]
            ]
        }]
    ]
})

route.group('/user1', [jwtMiddleware], () => {
    return [
        ['get', '/index', AuthController.index1],
    ]
})


export default route;